package com.dc.project.entity.vo;

import com.dc.project.entity.po.TaskDetailItem;
import com.own.component.common.base.entity.vo.BaseVo;
import com.own.constant.ConstantBeanSuffix;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * TaskDetailItemVo
 *
 * @author chenxueli
 * @date 2025-03-10 10:55:12
 */
@Schema(title = "任务详情分析内容" + ConstantBeanSuffix.VO)
@Getter
@Setter
@ToString
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class TaskDetailItemVo extends BaseVo<TaskDetailItem> implements Serializable {

    @Schema(title = "任务id")
    private Long taskId;

    @Schema(title = "任务详情id")
    private Long detailId;

    @Schema(title = "待提交文件的标题")
    private String title;

    @Schema(title = "待提交文件的描述")
    private String description;

    @Schema(title = "文件生成状态 1=正常 2=等待中 3=生成中 4=生成失败")
    private Integer generateStatus;

    @Schema(title = "任务类型 1=根据自定义文件创建 2=根据模板生成")
    private Integer type;

    @Schema(title = "模板key")
    private String templateKey;

    @Schema(title = "来源id")
    private Long sourceId;

    @Schema(title = "任务文件提交数据")
    private List<TaskFileCommitVo> commitList = new ArrayList<>();

    @Schema(title = "生成的文件列表")
    private List<TaskResultGenerateVo> generateList = new ArrayList<>();

    /**
     * 构造方法
     *
     * @param entity 原对象
     */
    public TaskDetailItemVo(@NonNull TaskDetailItem entity) {
        super(entity);
        this.taskId = entity.getFkTaskId();
        this.detailId = entity.getFkDetailId();
        this.title = entity.getTitle();
        this.description = entity.getDescription();
        this.generateStatus = entity.getGenerateStatus();
        this.type = entity.getType();
        this.templateKey = entity.getTemplateKey();
        this.sourceId = entity.getFkSourceId();
    }

    /**
     * 转po对象
     *
     * @param entity 原对象
     * @return po对象
     */
    @Override
    public TaskDetailItem toPo(TaskDetailItem entity) {
        if (entity == null) {
            entity = new TaskDetailItem();
        }
        entity.setFkTaskId(this.taskId);
        entity.setFkDetailId(this.detailId);
        entity.setTitle(this.title);
        entity.setDescription(this.description);
        entity.setGenerateStatus(this.generateStatus);
        entity.setType(this.type);
        entity.setTemplateKey(this.templateKey);
        entity.setFkSourceId(this.sourceId);
        return super.toPo(entity);
    }

}
